package com.rentong.wx.cust.controller;

import com.rentong.common.R;
import com.rentong.wx.cust.service.CustMessageChatTopService;
import com.rentong.wx.utils.WxApiUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author zhangle
 * @email 459343178@qq.com
 * @date 2024-12-24 14:42:32
 */
@RestController
public class CustMessageChatTopController {

    @Autowired
    private CustMessageChatTopService custMessageChatTopService;


    /*
     * 13、消息置顶
     *
     * */
    @Transactional(rollbackFor = Exception.class)
    @PostMapping("/custMessageChatTop/insertPinMessage")
    public R insertPinMessage(Long userId, HttpServletRequest request)throws Exception{
        Integer integer = custMessageChatTopService.insertPinMessage(userId, WxApiUtil.getCurrentCustId(request));

        if (integer > 0){
            return R.success("操作成功");
        }else {
            return R.error("操作失败");
        }
    }


    /*
     *14、取消消息置顶
     *
     * */
    @Transactional(rollbackFor = Exception.class)
    @DeleteMapping("/custMessageChatTop/deleteCancelPinMessage")
    public R deleteCancelPinMessage(Long chatTopId){
        Integer integer = custMessageChatTopService.deleteCancelPinMessage(chatTopId);

        if (integer > 0){
            return R.success("操作成功");
        }else {
            return R.error("操作失败");
        }
    }




}
